// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_img;

import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.*;
import android.net.Uri;
import android.util.DisplayMetrics;
import com.nnee.p_g.cls_b;
import java.io.*;

public class cls_c
{

    public cls_c()
    {
    }

    public static int a(Context context, float f)
    {
        return (int)(0.5F + f * context.getResources().getDisplayMetrics().density);
    }

    public static Bitmap a(Context context, Uri uri, int i, int j)
    {
        InputStream inputstream1=null;
    	Bitmap bitmap = null;
        if(uri != null) {
        	InputStream inputstream=null;
            android.graphics.BitmapFactory.Options options;
            Bitmap bitmap1;
            float f;
            float f1;
            try
            {
                inputstream = context.getContentResolver().openInputStream(uri);
            }
            catch(FileNotFoundException filenotfoundexception)
            {
                filenotfoundexception.printStackTrace();
                bitmap = null;
                return bitmap;
            }
            options = new android.graphics.BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            bitmap1 = BitmapFactory.decodeStream(inputstream, null, options);
            if(bitmap1 != null)
                bitmap1.recycle();
            options.inJustDecodeBounds = false;
            try
            {
                inputstream.close();
            }
            catch(IOException ioexception)
            {
                ioexception.printStackTrace();
            }
            f = (float)options.outWidth / (float)i;
            f1 = (float)options.outHeight / (float)j;
            options.inSampleSize = 1;
            if(f > 1F || f1 > 1F)
            {
            
            
                if(f <= f1)
                    f = f1;
                options.inSampleSize = (int)(f + 0.9F);
            }
            try {
				inputstream1 = context.getContentResolver().openInputStream(uri);
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            bitmap = BitmapFactory.decodeStream(inputstream1, null, options);
            try
            {
                inputstream1.close();
            }
            // Misplaced declaration of an exception variable
            catch(IOException ioexception1)
            {
                ioexception1.printStackTrace();
            }
             
        }
 
        return bitmap;
 
    }

    public static Bitmap a(Bitmap bitmap)
    {
        Bitmap bitmap1 = null;
        if(bitmap != null) {
        	int i;
            int j;
            i = bitmap.getWidth();
            j = bitmap.getHeight();
            bitmap1 = Bitmap.createBitmap(i, j, android.graphics.Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap1);
            Paint paint = new Paint();
            Rect rect = new Rect(0, 0, i, j);
            RectF rectf = new RectF(rect);
            paint.setAntiAlias(true);
            canvas.drawARGB(0, 0, 0, 0);
            paint.setColor(0xff424242);
            canvas.drawRoundRect(rectf, 5F, 5F, paint);
            paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.SRC_IN));
            canvas.drawBitmap(bitmap, rect, rect, paint);
            if(bitmap != null)
                bitmap.recycle();
           
        }

        return bitmap1;
  
 
    }

    static Bitmap a(Bitmap bitmap, int i)
    {
        Matrix matrix;
        if(i == 0 || bitmap == null)
            return null;
        matrix = new Matrix();
        matrix.setRotate(i, (float)bitmap.getWidth() / 2F, (float)bitmap.getHeight() / 2F);
        Bitmap bitmap1;
        int j = bitmap.getWidth();
        int k = bitmap.getHeight();
        bitmap1 = Bitmap.createBitmap(bitmap, 0, 0, j, k, matrix, true);
        if(bitmap == bitmap1)
        	return null;
        bitmap.recycle();
        bitmap = bitmap1;
 
        return bitmap;
        
    }

    public static Bitmap a(Bitmap bitmap, int i, int j)
    {
        Bitmap bitmap1;
        if(bitmap == null)
        {
            bitmap1 = null;
        } else
        {
            int k = bitmap.getWidth();
            int l = bitmap.getHeight();
            float f = (float)i / (float)k;
            float f1 = (float)j / (float)l;
            Matrix matrix;
            if(f >= f1)
                f1 = f;
            matrix = new Matrix();
            matrix.postScale(f1, f1);
            bitmap1 = Bitmap.createBitmap(bitmap, 0, 0, k, l, matrix, true);
        }
        return bitmap1;
    }

    public static Bitmap a(String s)
    {
        Bitmap bitmap = null;
        if(s != null) {
        	android.graphics.BitmapFactory.Options options;
            File file = new File(s);
            if(!file.isFile() || !file.exists())
                return null; /* Loop/switch isn't completed */
            float f = (float)file.length() / a;
            options = new android.graphics.BitmapFactory.Options();
            options.inJustDecodeBounds = false;
            options.inSampleSize = 1;
            if(f > 1F)
                options.inSampleSize = (int)(f + 0.5F);
            Bitmap bitmap1 = BitmapFactory.decodeFile(s, options);
            bitmap = bitmap1;
            
        }
 
        return bitmap;

    }

    public static Bitmap a(String s, int i, int j)
    {
        Bitmap bitmap = null;
        if(s != null) {
        	android.graphics.BitmapFactory.Options options;
            Bitmap bitmap1;
            options = new android.graphics.BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            bitmap1 = BitmapFactory.decodeFile(s, options);
            Bitmap bitmap2;
            bitmap2 = bitmap1;
            if(bitmap2 == null)
                return null;
            bitmap2.recycle();
            bitmap2 = bitmap;
            float f;
            float f1;
            options.inJustDecodeBounds = false;
            f = (float)options.outWidth / (float)i;
            f1 = (float)options.outHeight / (float)j;
            options.inSampleSize = 1;
            if(f <= 1F && f1 <= 1F) {
            	 
            } else {
            	if(f <= f1) {
            		 f = f1;
            		 options.inSampleSize = (int)(f + 0.9F);
            	} else 
            	{
            		options.inSampleSize = (int)(f + 0.9F);
            	}
            }
            
            Bitmap bitmap3 = BitmapFactory.decodeFile(s, options);
            bitmap = bitmap3;
        }
 
        return bitmap;
 
    }

    public static boolean a(Bitmap bitmap, String s, android.graphics.Bitmap.CompressFormat compressformat)
    {
        boolean flag = false;
        FileOutputStream fileoutputstream=null;
        if(!(new File(s)).exists())
			try {
				(new File(s)).createNewFile();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        try {
			fileoutputstream = new FileOutputStream(s);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        flag = bitmap.compress(compressformat, 100, fileoutputstream);
 
        return flag;
        
    }

    public static int b(Context context, float f)
    {
        return (int)(0.5F + f / context.getResources().getDisplayMetrics().density);
    }

    public static Bitmap b(Bitmap bitmap)
    {
    	Bitmap bitmap2 = null;
        if(bitmap != null) {
        	int i;
            int j;
            i = bitmap.getWidth();
            j = bitmap.getHeight();
            Bitmap bitmap3 = Bitmap.createBitmap(i, j, android.graphics.Bitmap.Config.ARGB_8888);
            bitmap2 = bitmap3;
            Canvas canvas = new Canvas(bitmap2);
            Paint paint = new Paint();
            Rect rect = new Rect(0, 0, i, j);
            RectF rectf = new RectF(rect);
            paint.setAntiAlias(true);
            canvas.drawARGB(0, 0, 0, 0);
            paint.setColor(0xff424242);
            canvas.drawRoundRect(rectf, 5F, 5F, paint);
            paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.SRC_IN));
            canvas.drawBitmap(bitmap, rect, rect, paint);
            if(bitmap == null);
            	return bitmap2;
            
            
            
        }
 
        return bitmap2;
 
    }

    public static Bitmap b(Bitmap bitmap, int i, int j)
    {
    	Bitmap bitmap1 = null;
        if(bitmap != null) {
        	int k = bitmap.getWidth();
            int l = bitmap.getHeight();
            float f = (float)i / (float)k;
            float f1 = (float)j / (float)l;
            Matrix matrix;
            if(f >= f1)
                f1 = f;
            matrix = new Matrix();
            matrix.postScale(f1, f1);
            bitmap1 = Bitmap.createBitmap(bitmap, 0, 0, k, l, matrix, true);
            if(bitmap1 != bitmap)
                bitmap.recycle();
        }
        return bitmap1;

    }

    public static Bitmap c(Bitmap bitmap, int i, int j)
    { Bitmap bitmap1= null;
      bitmap = null;
        if(bitmap != null) {
        	int k = bitmap.getWidth();
            int l = bitmap.getHeight();
            float f = (float)i / (float)k;
            float f1 = (float)j / (float)l;
            if(f < 1F || f1 < 1F)
            {
                Matrix matrix;
               
                if(f >= f1)
                    f = f1;
                matrix = new Matrix();
                matrix.postScale(f, f);
                bitmap1 = Bitmap.createBitmap(bitmap, 0, 0, k, l, matrix, true);
                bitmap.recycle();
                bitmap = bitmap1;
            }
        }
		return bitmap;
 
 
    }

    private static float a = 512000F;

}
